﻿@using Home.Domain.Entities
@model List<Brand>
@{
    ViewBag.SidebarId = 32;
    ViewBag.Title = "品牌列表";
    Layout = "~/Areas/Mythi/Views/Shared/_Layout.cshtml";
}
@section loadend{
    $("[name='Delete']").click(
    function () {
        if (confirm("确定要删除\"" + $(this).attr("tip") + "\"吗？")) {
            var stuid = $(this).attr("stuid");
            var tr = $(this).parent().parent();
            $.post("@Url.Action("Delete")", { id: stuid }, function (data) {
                 if (data == "-1") { alert("删除失败"); }
                 if (data > 0) {
                     alert("此分类中有" + data + "项,请先删除内容项");
                 }
                 else {
                     $(tr).remove(); alert("删除成功");
                 }
             });
         }
    });
    }
<table class="table table-bordered">
  <thead>
    <tr>
      <th>标题</th>
      <th>操作</th>
    </tr>
  </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td>@item.Title</td>
                <td>
                   <a href="@Url.Action("Edit", new {id=item.Id })">编辑</a> 
                   <a href="javascript:void(0)" name="Delete" tip="@item.Title" stuid="@item.Id">删除</a>
                    <a href="@Url.Action("Up", new {id=item.Id })">上移</a>
                </td>
            </tr>
       }
    </tbody>
</table>

